package com.itheima.consumer.listener;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class DirectExchangeListener2 {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "direct.queue3",durable = "true"),
            exchange = @Exchange(name = "direct.exchange",type = ExchangeTypes.DIRECT),
            key = {"direct.key"}
    ))
    public void listenerDirectExchangeMessage(String message){
        System.out.println("接收到的消息是"+message);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "direct.queue4",durable = "true"),
            exchange = @Exchange(name = "direct2.exchange",type = ExchangeTypes.DIRECT),
            key = {"direct.key2"}
    ))
    public void listenerDirectExchangeMessage2(String message){
        System.out.println("接收到的消息是"+message);
    }
}
